package cn.me.alphamq.vo;

/**
 * 响应
 *
 * @author f
 */
public class Response {

    private int code;
    private String msg;
    private Object data;

    private Response() {}

    private Response(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static Response ok() {
        return ok(null);
    }

    public static Response ok(Object data) {
        return new Response(200, null, data);
    }

    public static Response fail() {
        return error(null);
    }

    public static Response badRequest(String msg) {
        return fail(400, msg);
    }

    public static Response error(String msg) {
        return fail(500, msg);
    }

    public static Response fail(int code, String msg) {
        return new Response(code, msg, null);
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
